package com.numberone.iotplatform.service;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.stereotype.Service;

@Service
public class WebSocketMessagingService {
    @Autowired
    private SimpMessagingTemplate messagingTemplate;

    /**
     * 向指定的主题（topic）发送消息。
     * @param topic   目标主题，例如 "/topic/scan-progress"
     * @param payload 要发送的消息对象
     */
    public void sendMessage(String topic, Object payload) {
        messagingTemplate.convertAndSend(topic, payload);
    }
}